Expand description
Library and binaries for the reading, creating, and modification of SquashFS file systems.
§Library
Add the following to your Cargo.toml
file:
[dependencies]
backhand = "0.15.0"
§Reading
For reading an image and extracting its details and contents, use
FilesystemReader::from_reader
.
§Writing
For creating a modified or new image, use FilesystemWriter::from_fs_reader
.
FilesystemWriter
can also be created from scratch, without a previous image to base itself
on.
§Example
// read
let file = BufReader::new(File::open("file.squashfs").unwrap());
let read_filesystem = FilesystemReader::from_reader(file).unwrap();
// convert to writer
let mut write_filesystem = FilesystemWriter::from_fs_reader(&read_filesystem).unwrap();
// add file with data from slice
let d = NodeHeader::default();
let bytes = Cursor::new(b"Fear is the mind-killer.");
write_filesystem.push_file(bytes, "a/d/e/new_file", d);
// add file with data from file
let new_file = File::open("dune").unwrap();
write_filesystem.push_file(new_file, "/root/dune", d);
// replace a existing file
let bytes = Cursor::new(b"The sleeper must awaken.\n");
write_filesystem
.replace_file("/a/b/c/d/e/first_file", bytes)
.unwrap();
// write into a new file
let mut output = File::create("modified.squashfs").unwrap();
write_filesystem.write(&mut output).unwrap();
§Features
xz
(enabled by default) — Enables xz compression inside library and binariesxz-static
— Enables xz compression and forces static build inside library and binariesgzip
(enabled by default) — Enables gzip compression inside library and binariesgzip-zune-inflate
— Enables faster gzip (de-compression only) inside library and binaries Cannot be used with thegzip
featurelzo
— This library is licensed GPL and thus disabled by defaultzstd
(enabled by default) — Enables zstd compression inside library and binaries
Modules§
- Compression Choice and Options
- Support the wonderful world of vendor formats
Structs§
- NFS export support
- Xz compression option for
FilesystemWriter
- All compression options for
FilesystemWriter
- Representation of SquashFS filesystem after read from image
- Filesystem handle for file
- Representation of SquashFS filesystem to be written back to an image
- 32 bit user and group IDs
- Filesystem Node
- File information for Node
- Squashfs Image initial read information
- Block Device for filesystem
- Character Device for filesystem
- Directory for filesystem
- Unread file for filesystem
- Symlink for filesystem
- Contains important information about the archive, including the locations of other sections
Enums§
- Errors generated from library
- Compression options only for
FilesystemWriter
- Filesystem node
- Read file from other SquashfsFile or an user file
Constants§
- 128KiB
- 4KiB
- 1MiB
- 4KiB
Traits§
- Pseudo-Trait for BufRead + Seek